<template>
  <div class="strategic-matrix">
    <div class="matrix-header">
      <h3>参与者动机分析</h3>
      <div class="matrix-legend">
        <span class="legend-item high">高置信度</span>
        <span class="legend-item medium">中置信度</span>
        <span class="legend-item low">低置信度</span>
      </div>
    </div>
    
    <div class="matrix-content">
      <div 
        v-for="(goals, participant) in matrixData" 
        :key="participant"
        class="participant-goals"
      >
        <div class="participant-header">
          <h4>{{ participant }}</h4>
        </div>
        
        <div class="goals-list">
          <div 
            v-for="goal in goals" 
            :key="goal.goal"
            class="goal-item"
            :class="`confidence-${goal.confidence}`"
          >
            <div class="goal-header">
              <span class="goal-title">{{ goal.goal }}</span>
              <span class="goal-confidence">{{ confidenceMap[goal.confidence] }}</span>
            </div>
            
            <div class="goal-evidence">
              <h5>支持证据:</h5>
              <ul>
                <li v-for="evidence in goal.supportingEvidence" :key="evidence">
                  {{ evidence }}
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import type { PropType } from 'vue';
import type { MotivationMatrix } from '../../types/analysis';

// 定义属性
defineProps({
  matrixData: {
    type: Object as PropType<MotivationMatrix>,
    required: true
  }
});

// 信心度映射
const confidenceMap: Record<string, string> = {
  high: '高',
  medium: '中',
  low: '低'
};
</script>

<style scoped>
.strategic-matrix {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.matrix-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.matrix-header h3 {
  font-size: 1.25rem;
  color: #1a2b4e;
  margin: 0;
}

.matrix-legend {
  display: flex;
  gap: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  font-size: 0.875rem;
  color: #64748b;
}

.legend-item::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border-radius: 3px;
}

.legend-item.high::before {
  background-color: #10b981;
}

.legend-item.medium::before {
  background-color: #f59e0b;
}

.legend-item.low::before {
  background-color: #ef4444;
}

.matrix-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.participant-goals {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.participant-header {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.participant-header h4 {
  margin: 0;
  font-size: 1.125rem;
  color: #1a2b4e;
}

.goals-list {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.goal-item {
  border-radius: 6px;
  padding: 1rem;
  border-left: 4px solid transparent;
}

.goal-item.confidence-high {
  background-color: rgba(16, 185, 129, 0.1);
  border-left-color: #10b981;
}

.goal-item.confidence-medium {
  background-color: rgba(245, 158, 11, 0.1);
  border-left-color: #f59e0b;
}

.goal-item.confidence-low {
  background-color: rgba(239, 68, 68, 0.1);
  border-left-color: #ef4444;
}

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.goal-title {
  font-weight: 600;
  color: #1a2b4e;
}

.goal-confidence {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

.confidence-high .goal-confidence {
  background-color: rgba(16, 185, 129, 0.2);
  color: #065f46;
}

.confidence-medium .goal-confidence {
  background-color: rgba(245, 158, 11, 0.2);
  color: #92400e;
}

.confidence-low .goal-confidence {
  background-color: rgba(239, 68, 68, 0.2);
  color: #b91c1c;
}

.goal-evidence h5 {
  font-size: 0.875rem;
  color: #64748b;
  margin: 0 0 0.5rem 0;
}

.goal-evidence ul {
  margin: 0;
  padding-left: 1.25rem;
}

.goal-evidence li {
  font-size: 0.875rem;
  color: #334155;
  margin-bottom: 0.25rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .matrix-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  
  .matrix-content {
    grid-template-columns: 1fr;
  }
}
</style>
